home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 7.3 KB | 217 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UDocumentSkeleton.cp
- // Copyright © 1991-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- /*
- Changes
- 3/21/96 srf The "SquareDots" parameter of IStdPrintHandler is obsolete
- */
-
- #ifndef __UDOCUMENTSKELETON__
- #include "UDocumentSkeleton.h"
- #endif
-
- // Skeleton
-
- #ifndef __UCOMMANDSKELETON__
- #include "UCommandSkeleton.h"
- #endif
-
- #ifndef __UVIEWSKELETON__
- #include "UViewSkeleton.h"
- #endif
-
- // MacApp
-
- #ifndef __UMACAPPGLOBALS__
- #include "UMacAppGlobals.h"
- #endif
-
- #ifndef __UMENUMGR__
- #include "UMenuMgr.h"
- #endif
-
- #ifndef __UPRINTING__
- #include "UPrinting.h"
- #endif
-
- #ifndef __UVIEWSERVER__
- #include "UViewServer.h"
- #endif
-
- #ifndef __UWINDOW__
- #include "UWindow.h"
- #endif
-
- //----------------------------------------------------------------------------------------
- // Constants:
-
- const ResNumber kSkeletonWindowID = kDefaultWindowID;
-
- //========================================================================================
- // CLASS TDocumentSkeleton
- //========================================================================================
- #undef Inherited
- #define Inherited TFileBasedDocument
-
- #pragma segment AOpen
- MA_DEFINE_CLASS_M1(TDocumentSkeleton, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton constructor
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- TDocumentSkeleton::TDocumentSkeleton()
- {
- } // TDocumentSkeleton::TDocumentSkeleton
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::IDocumentSkeleton:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- void TDocumentSkeleton::IDocumentSkeleton(TFile* itsFile,
- OSType itsCreator)
- {
- this->IFileBasedDocument(itsFile,itsCreator);
- } // TDocumentSkeleton::IDocumentSkeleton
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton destructor
- //----------------------------------------------------------------------------------------
- #pragma segment AClose
-
- TDocumentSkeleton::~TDocumentSkeleton()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::FreeData:
- //----------------------------------------------------------------------------------------
- #pragma segment AClose
-
- void TDocumentSkeleton::FreeData() // Override
- {
- Inherited::FreeData();
- } // TDocumentSkeleton::FreeData
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoInitialState:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- void TDocumentSkeleton::DoInitialState() // Override
- {
- Inherited::DoInitialState();
- } // TDocumentSkeleton::DoInitialState
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoMakeViews:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- void TDocumentSkeleton::DoMakeViews(Boolean /*forPrinting*/) // Override
- {
- TWindow* aWindow = NULL;
- TStdPrintHandler* aHandler = NULL;
- TViewSkeleton* aViewSkeleton = NULL;
-
- FailNIL(aWindow = gViewServer->NewTemplateWindow(kSkeletonWindowID, this));
-
- aViewSkeleton = (TViewSkeleton*) (aWindow->FindSubView('SKEL')); // Must cast because FindSubView returns TView
-
- aHandler = new TStdPrintHandler;
- aHandler->IStdPrintHandler(this, // its document
- aViewSkeleton, // its view
- kFixedSize, // horzontal page size is fixed
- kFixedSize); // vertical page size is fixed
- } // TDocumentSkeleton::DoMakeViews
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoNeedDiskSpace:
- //----------------------------------------------------------------------------------------
- #pragma segment AWriteFile
-
- void TDocumentSkeleton::DoNeedDiskSpace(TFile* itsFile,
- long& dataForkBytes,
- long& rsrcForkBytes) // Override
- {
- Inherited::DoNeedDiskSpace(itsFile, dataForkBytes, rsrcForkBytes);
- } // TDocumentSkeleton::DoNeedDiskSpace
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoMenuCommand: This method is overridden to handle menu items which
- // are enabled when this document is in the target chain. In this example, this is true
- // when the document is open and its window is the active window. The inherited method
- // should always be called so that MacApp can allow successor objects in the target chain
- // (i.e. the application) to handle THEIR menu items.
- //----------------------------------------------------------------------------------------
- #pragma segment ASelCommand
-
- void TDocumentSkeleton::DoMenuCommand(CommandNumber aCommandNumber) // Override
- {
- switch (aCommandNumber)
- {
- case cCommandHandledByDocument:
- {
- TCommandSkeleton* aCommand = new TCommandSkeleton;
- aCommand->ICommandSkeleton(aCommandNumber, this);
- this->PostCommand(aCommand);
- }
- break;
- default:
- Inherited::DoMenuCommand(aCommandNumber);
- break;
- }
- } // TDocumentSkeleton::DoMenuCommand
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoRead:
- //----------------------------------------------------------------------------------------
- #pragma segment AReadFile
-
- void TDocumentSkeleton::DoRead(TFile* aFile,
- Boolean forPrinting) // Override
- {
- Inherited::DoRead(aFile,forPrinting);
- } // TDocumentSkeleton::DoRead
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoSetupMenus: This method is overridden to enable menu items which
- // should be enabled when this object is in the target chain. MacApp initially disables
- // all menu items, then lets the objects in the target chain enable those items they
- // handle.
- //
- // A document object is in the target chain when its window is the active window.
- //
- // The inherited method is called so that TDocument can enable document-level menu items
- // like "Save ". This also ensures that objects further up the target chain (the
- // application) can set up THEIR menus.
- //----------------------------------------------------------------------------------------
- #pragma segment ARes
-
- void TDocumentSkeleton::DoSetupMenus() // Override
- {
- Inherited::DoSetupMenus();
-
- Enable(cCommandHandledByDocument,TRUE);
- } // TDocumentSkeleton::DoSetupMenus
-
- //----------------------------------------------------------------------------------------
- // TDocumentSkeleton::DoWrite:
- //----------------------------------------------------------------------------------------
- #pragma segment AWriteFile
-
- void TDocumentSkeleton::DoWrite(TFile* aFile,
- Boolean makingCopy) // Override
- {
- Inherited::DoWrite(aFile,makingCopy);
- } // TDocumentSkeleton::DoWrite
-
- //----------------------------------------------------------------------------------------
- // End of UDocumentSkeleton.cp
-
- #pragma segment Inline
-